home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / listErr.bat < prev    next >
DOS Batch File  |  1993-09-26  |  2KB  |  74 lines

  1. @echo off
  2. !  listErr.bat    Batch file to list all the error messages
  3. !
  4. !  listErr  [filename]
  5. !
  6. !  where 'filename' is the file into which the list is to be stored.
  7. !  If the filename is missing, the listing is done on the screen.
  8. !  Additional parameters are ignored.
  9. !
  10. !  Note that error messages consist of a single line of text.
  11. !
  12. !  Copyright © 1993 by Rainbow Hill Pty Ltd. All rights reserved.
  13. !
  14.  
  15.     ! initialisation
  16.     onerror ERR_LBL
  17.     ! the maximum is 256, but we do not want to waste time
  18.     set    maxerr=90
  19.  
  20.     ! first check whether the user has provided the filename
  21.     ! pre-set the fileID to zero which will be used to indicate the monitor
  22.     set fileID=0
  23.     if "%1 " == " " goto FTEST_DONE_LBL
  24.         if exist %1 del %1
  25.         open/w "%1" fileID
  26.         :FTEST_DONE_LBL
  27.  
  28.     ! initialise the error code
  29.     set k=1
  30.  
  31.     ! loop to obtain, process, and then store all the messages
  32.     repeat ERR_LOOP_LBL
  33.  
  34.         ! obtain a message
  35.         show %k% result
  36.  
  37.         ! We have to check the result to ensure that the error code has a message,
  38.         ! but we only check the first word of the message otherwise we could cause
  39.         ! a command line overflow.
  40.         ! Before searching for the first space in the result, we make sure that
  41.         ! there is one by appending it to the end.
  42.         set first_word=%result%
  43.         incr first_word by " "
  44.         sstr first_word " "
  45.         ! we have to add something (eg. an @) in order to ensure that it works when
  46.         ! the first word is the string "not"
  47.         if %first_word%@ == %k%@ goto NEXT_ERR_LBL
  48.             if %fileID% == 0 goto TO_SCREEN_LBL
  49.                 write %fileID% "%k%: %result%"
  50.                 goto NEXT_ERR_LBL
  51.             :TO_SCREEN_LBL
  52.                 echo %k%: %result%
  53.             :NEXT_ERR_LBL
  54.  
  55.         ! check whether we have processed all the errors
  56.         incr k
  57.         if %k% == %maxerr% goto X_ERR_LOOP_LBL
  58.         :ERR_LOOP_LBL
  59. :X_ERR_LOOP_LBL
  60.  
  61.     ! reset doserr so that we can fall through
  62.     set doserr=0
  63.  
  64. :ERR_LBL
  65.     if not %doserr% == 0 show %doserr%
  66.  
  67. :DONE_LBL
  68.     if not %fileID% == 0 close %fileID%
  69.     set result=
  70.     set maxerr=
  71.     set k=
  72.     set first_word=
  73.     set fileID=
  74.